<div id="tiga_ba">
	<div id="tiga_baa">Data Penduduk </div>
	<div id="tiga_bac" style="float:right">
		<a href="utama.php?module=mod_bantuan&view=penduduk" target="_BLANK">
			<img src="asset/images/bantuan.png" width="30">
		</a>
	</div>
	<!--<div id="tiga_bab">
		<a href="javascript:void(0)" onClick="location.href='utama.php?module=mod_penduduk&view=form_tambah'">
			<button class="button">Tambah</button>
		</a>
	</div>-->
	<div class="clear"></div>
</div>

<?php
	if(!empty($_GET['nama'])){
		$param_nama=$_GET['nama'];
		$jenis=$_GET['jenis'];
	}else{
		$param_nama=$_POST['nama'];
		$jenis=$_POST['jenis_cari'];
	}

?>

<table style="margin-left: 5px;" width="830" >
	<tr>
		<form method=post action='utama.php?module=mod_penduduk'>
		<td width="65">Pencarian  : </td>
		<td width="200"><input type="text" name="nama" value="<?php echo $param_nama; ?>" class="input_field" /></td>
		<td><input name="submit" type="submit" class="button" value="Cari" /></td>
		</form>
		<form method="post" enctype="multipart/form-data" action="module/mod_penduduk/proses_import.php">
		<td>Import File Excel:</td>
		<td><input name="userfile" type="file"></td>
		<td><input name="upload" type="submit" class="button" value="Import"></td>
		</form>
		<td align="right"><a href="utama.php?module=mod_penduduk&view=sinkronisasi"><img src="asset/images/sinkronisasi.png" title="Sikronisasi Data Peserta BPJS" width="30"></a></td>
		<td align="right"><a href="module/mod_penduduk/cetak.php"><img src="asset/images/print.png" width="30"></a></td>
	</tr>
</table>


<table class="tabel">
	<tr>
		<th>NO</th>
		<th>Aksi</th>
		<th>NIK</th>
		<th>Nama</th>
		<th>JK</th>
		<th>Tempat Lahir</th>
		<th>Tanggal Lahir</th>
		<th>Pekerjaan</th>
		<th>Status</th>
		<th>BPJS</th>
	</tr>
	<?php
		$p= new paging ;
		$batas= 10;

		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		$sql="select * from penduduk p inner join agama a on p.id_agama = a.id_agama inner join pendidikan pd on p.id_pendidikan = pd.id_pendidikan inner join pekerjaan pk on p.id_pekerjaan = pk.id_pekerjaan inner join status_nikah s on p.id_status = s.id_status inner join hub_keluarga h on p.id_hub_keluarga = h.id_hub_keluarga where nik like '%$param_nama%' order by id_penduduk desc limit $posisi,$batas";
		//echo $sql;
		$qry=mysql_query($sql);
		$no=$posisi + 1;
		if(mysql_num_rows($qry)>0){
		
			while($hasil=mysql_fetch_array($qry)){
	?>
				<tr>
					<td align="center" width="30"><?php echo $no;?></td>
					<td align="center" width="60">
						<a href="utama.php?module=mod_penduduk&view=form_edit&id=<?php echo $hasil['id_penduduk'];?>">
						<img src="asset/images/edit.png" title="Ubah Data"></a> 
						<a href="utama.php?module=mod_penduduk&act=hapus&id=<?php echo $hasil['id_penduduk'];?>" onclick="return confirm('Anda yakin ingin Menghapus Data ?')"><img src="asset/images/delete.png" title="Hapus Data"></a>
					</td>
					<td align="center" width="60"><?php echo $hasil['nik'];?></td>
					<td ><?php echo $hasil['nama'];?></td>
					<td ><?php echo $hasil['jk'];?></td>
					<td ><?php echo $hasil['tempat_lahir'];?></td>
					<td ><?php echo tgl_ind("$hasil[tgl_lahir]");?></td>
					<td ><?php echo $hasil['pekerjaan'];?></td>
					<td >
						<?php 
							if($hasil['is_miskin'] == 'Y'){
								echo "Miskin";
							}else{
								echo "Tidak Miskin";
							}
						?>
					</td>
					<td align="center">
						<?php 
							if($hasil['bpjs'] == 'Y'){
								echo "Ya";
							}else{
								echo "Tidak";
							}
						?>
					</td>
				</tr>
				
		<?php
				$no++;
			}
		}else{
		?>
	
	<tr>
		<td colspan="11" align="center">Data tidak Ada </td>
	</tr>
	
	<?php
		}
	?>
</table>

<?php
	$sql2="select * from penduduk p inner join agama a on p.id_agama = a.id_agama inner join pendidikan pd on p.id_pendidikan = pd.id_pendidikan inner join pekerjaan pk on p.id_pekerjaan = pk.id_pekerjaan inner join status_nikah s on p.id_status = s.id_status inner join hub_keluarga h on p.id_hub_keluarga = h.id_hub_keluarga where nik like '%$param_nama%'" ;
	$query2=mysql_query($sql2);
	$jumlah_data=mysql_num_rows($query2);
	//dapatkan jumlah halaman
	$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
	//cetak link
	$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?module=mod_penduduk","nama=$param_nama");
	print($linkhalaman);
?>
        